package bairui.international.console.web.controller.barter.category.product;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lianjing.sh.spring.web.controller.base.action.Action;
import com.lianjing.sh.spring.web.controller.enhance.output.FomatOutput;

import bairui.international.service.Service_Product;
import bairui.international.service.Service_Product_Generate;

/**
 *
 * 物料删除
 *
 * @generated
 * 
 * @see STest_C_Barter_Category_ProductDelete_Delete 测试
 *
 */
@Controller
public class C_Barter_Category_ProductDelete_Delete
 extends SC_Barter_Category_ProductDelete_Delete 
{

	@Autowired private Service_Product_Generate service_Product_Generate;
	@Autowired private Service_Product service_Product;
	
	/**
	 * 删除
	 */
	@Action(Delete.class)
	@DeleteMapping(Delete.RequestMappingValue)
	public @FomatOutput @ResponseBody Object delete(
		@PathVariable(name=Delete.PathVariableName.CategoryId) long categoryId, 
		@PathVariable(name=Delete.PathVariableName.Id) long id
	) throws Exception {
		service_Product.findById(id).getState()
			.validator()
			.v_Draft()
			.end();
		//
		service_Product_Generate.deleteById(id);
		//
		return null;
	}
	

}
